package interview;

import java.util.HashSet;
import java.util.Set;

/**
 * Created by richard on 6/3/14.
 */
public class RemoveCharactorFromString {
    public static String removeChar(String src,String remove){
        Set<Character> toBeRemovedCharMap = new HashSet<>();// use a hash for efficient
        int MASK=1;
        StringBuilder stringBuilder = new StringBuilder();
        if(src==null){
            throw new IllegalArgumentException("Source string is null");

        }
        if(src.length()==0){
            return "";
        }
        //init the toBeRemovedCharMap
        for(int i=0;i<remove.length();i++){
           toBeRemovedCharMap.add(remove.charAt(i));
        }
        //scan the string need to be operated
        for(int i=0;i<src.length();i++){
            if(toBeRemovedCharMap.contains(src.charAt(i))){//contain the char
                continue;
            }
            else{
                stringBuilder.append(src.charAt(i));
            }
        }

        return stringBuilder.toString();

    }

    public static void main(String[] args){
        System.out.println("Result:"+removeChar("GMR VAST2 is a professional solution to provide VAR calculation","aeiou"));
    }
}
